﻿namespace TradePublish.SysThread.Grasp
{
    using TradePublish.Common;
    using log4net;
    using System;
    using System.Configuration;
    using System.Reflection;
    using System.Threading;
    using TradePublish.Common;

    public class IpThread
    {
        private Thread doThread;
        private ILog log = null;

        public IpThread()
        {
            this.log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        }

        public void start()
        {
            this.doThread = new Thread(new ThreadStart(this.threadWork));
            this.doThread.IsBackground = true;
            this.doThread.Start();
        }

        private void threadWork()
        {
            AppSettingsReader reader = new AppSettingsReader();
            while (true)
            {
                string newValue = new IPListDao().getIp();
                Global.DBLinkStrSQL = reader.GetValue("DBLinkStrSQL", typeof(string)).ToString().Replace("localhost", newValue);
                this.log.Info("本检测线程IpThread休息10分钟.");
                Thread.Sleep(0xea60);
            }
        }
    }
}

